#pragma once
#include"Hash_tables.h"
template<class K,class V>
struct mapkov {
	const K& operator()(const pair<K,V>&_kv) {
		return _kv.first;
	}
};

template<class K,class V, class hashfunc = hashfun<K>>
class unordered_map {
public:
	typedef typename hash_bucket::HashTable<K, pair<K, V>, mapkov<K, V>>::iterator iterator;
	bool insert(const pair<K,V>& kv) {
		return ht.insert(kv).second;
	}
	bool erase(const K& key) {
		return ht.erase(key);
	}
	iterator find(const K& key) {
		return ht.find(key);
	}
	iterator begin() {
		return ht.begin();
	}
	iterator end() {
		return ht.end();
	}

	V& operator[](const K&key) {
		pair<iterator, bool> ret=ht.insert(make_pair(key, V()));
		//return (*(ht.insert(make_pair(key, V())).first)).second;
		//return (ht.insert(make_pair(key, V())).first)->second;
		//return (*(ret.first)).second;
		return ret.first->second;
	}
	
private:
	hash_bucket::HashTable<K, pair<K,V>,mapkov<K,V>>ht;
};